function load(pageNow) {
    var userId = localStorage.getItem("userId");
    $.ajax({
        url : "easybuy/product/memberOrder",
        type : "get",
        dataType : "json",
        data : {"userId" : userId,"pageNow":pageNow},
        success : function (data) {
            $(".m_right").html("<p style=\"text-align: center\">订单列表</p>");
            for (var i = 0; i < data.page.list.length; i++) {
                $(".m_right").append("<table id='table"+i+"'  class=\"mem_tab\" style=\"width:1000px; text-align:center; margin-top:2px;\" cellspacing=\"0\" cellpadding=\"0\">\n" +
                            "<tr style='background-color: #ffb474'><td style='height: 40px;width: 150px'>用户名："+data.page.list[i].loginName+"</td>"+
                            "<td style='height: 40px;width: 350px'>订单号："+data.page.list[i].serialNumber+"</td>"+
                            "<td style='height: 40px;width: 250px'>地址："+data.page.list[i].userAddress+"</td>"+
                            "<td style='height: 40px;'>总花费：￥"+data.page.list[i].cost+"</td></tr>"+
                    "            </table>");
                $("#table"+i).append("<tr>" +
                    "<td>商品名称</td>"+
                    "<td>商品图片</td>"+
                    "<td>数量</td>"+
                    "<td>小计</td>"+
                    "</tr>");
                for (var j = 0; j < data.order_details.length; j++) {
                    if (data.page.list[i].id==data.order_details[j].orderId){
                        $("#table"+i).append("<tr>" +
                            "<td id='name"+j+"'>"+data.order_details[j].productId+"</td>"+
                            "<td id='fileName"+j+"'>"+data.order_details[j].productId+"</td>"+
                            "<td>"+data.order_details[j].quantity+"</td>"+
                            "<td>"+data.order_details[j].cost+"</td>"+
                            "</tr>");
                    }
                    for (var k = 0; k < data.products.length; k++) {
                        if (data.products[k].id==data.order_details[j].productId){
                            $("#name"+j).text(data.products[k].name);
                            $("#fileName"+j).html("<img src=\"images/"+data.products[k].fileName+"\" style='width: 100px;height: 100px'>");
                        }
                    }
                }
            }
            $(".m_right").append(
                "<a href='#' onclick='load(1)'>首页</a>\n" +
                "      <a href='#' onclick='load("+(data.page.pageNow-1)+")'>上一页</a>\n" +
                "      <span>"+data.page.pageNow+"/"+data.page.pageCount+"</span>\n" +
                "      <a href='#' onclick='load("+(data.page.pageNow+1)+")'>下一页</a>\n" +
                "      <a href='#' onclick='load("+data.page.pageCount+")'>尾页</a>");
        }
    })
}
$(function () {
    load(1);
});